package com.jixiang.user.config;


import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static com.jixiang.common.constants.CodeMqConstants.*;

@Configuration
public class CodeMqConfig {
    /**
     * 声明交换机
     * @return Direct类型交换机
     */
    @Bean
    public DirectExchange codeExchange(){
        return ExchangeBuilder.directExchange(MQ_EXCHANGE_CODE).build();
    }

    /**
     * 第1个队列
     */
    @Bean
    public Queue codeQueue(){
        return new Queue(MQ_QUEUE_CODE);
    }

    /**
     * 绑定队列和交换机
     */
    @Bean
    public Binding bindingQueue1WithRed(Queue codeQueue, DirectExchange codeExchange){
        return BindingBuilder.bind(codeQueue).to(codeExchange).with(MQ_ROUTINGKEY_CODE);
    }

}
